package com.example.usercenter.common;

/**
 * 统一封装返回对象工具类
 * @author 米饭好好吃
 */
public class ResultUtils {
    public static <T> Result<T> success(int code, T data, String message) {
        return new Result<>(code, data, message);
    }

    public static <T> Result<T> success(int code, T data) {
        return new Result<>(code, data);
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(200, data);
    }

    public static <T> Result<T> success() {
        return new Result<>(200, null, "ok");
    }

    public static <T> Result<T> fail(ErrorCode errorCode) {
        return new Result<>(errorCode.getCode(), null, errorCode.getMessage());
    }

    public static <T> Result<T> fail(int code, String msg) {
        return new Result<>(code, null, msg);
    }
}
